import request from '@/common/utils/request'
import {message} from 'ant-design-vue'

const business = {
  state: {
    clueConfig: false,
    customConfig: false,
  },
  mutations: {
    SET_BUSINESS_CONFIG: (state, config) => {
      state.clueConfig = false;
      config.forEach(item => {
        if (item.type == 1 || item.type == 2) {
          if (item.status == 1) {
            state.clueConfig = true;
          }
        } else if (item.type == 3) {
          state.customConfig = item.status == 1 ? true : false
        }
      })
    }
  },
  actions: {
    GET_BUSINESS_CONFIG: ({commit, state}) => {
      return new Promise(resolve => {
        request.get("/org", "/business/clue/getClueApprovalConfig").then(res => {
          const config = res.data;
          if (config) {
            commit("SET_BUSINESS_CONFIG", config);
            resolve(res.data)
          }
        })
      })
    },
  },
}

export default business